package com.lijz.config;

import com.lijz.interceptor.AuthorizationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @author lijingzhao
 * @date 2018/10/24 22:25
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
	@Autowired
	private AuthorizationInterceptor authorizationInterceptor;
	@Override
	protected void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(authorizationInterceptor).addPathPatterns("/**")
				.excludePathPatterns("/error");//防止和统一异常拦截器影响  重复进入
		super.addInterceptors(registry);
	}
/*-------------------------------------一般情况默认就可以，也可以单独配置（也可以在配置文件中配置）----------------------------------------*/
//	/**
//	 * 过滤druid
//	 * @return
//	 */
//	@Bean
//	public FilterRegistrationBean druidStatFilter() {
//		FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter());
//		// 添加过滤规则.
//		filterRegistrationBean.addUrlPatterns("/*");
//		// 添加不需要忽略的格式信息.
//		filterRegistrationBean.addInitParameter("exclusions", "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*");
//		return filterRegistrationBean;
//	}
//
//
//	/**
//	 * 禁用springmvc 后缀匹配
//	 * @param configurer
//	 */
//	@Override
//	public void configurePathMatch(PathMatchConfigurer configurer) {
//		configurer.setUseSuffixPatternMatch(false);
//		super.configurePathMatch(configurer);
//	}
/*-------------------------------------------------end-----------------------------------------------------*/

}
